import request from "@/utils/request"
const BASE_URL = process.env.VUE_APP_BASE_URL

export function depDeleteAPI(data) {
	return request({
		url: BASE_URL + "adminDept/deleteDept/" + data.id,
		method: "post"
	})
}

export function depEditAPI(data) {
	return request({
		url: BASE_URL + "adminDept/setDept",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

export function depSaveAPI(data) {
	return request({
		url: BASE_URL + "adminDept/addDept",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

export function userEditAPI(params) {
	return request({
		url: BASE_URL + "adminUser/setUser",
		method: "post",
		data: params,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

export function userAddAPI(params) {
	return request({
		url: BASE_URL + "adminUser/addUser",
		method: "post",
		data: params,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

// 角色列表
export function roleListAPI(data) {
	return request({
		url: BASE_URL + "adminRole/getAllRoleList",
		method: "post",
		data: data
	})
}

// 查询系统默认角色
export function adminRoleQueryDefaultAPI() {
	return request({
		url: BASE_URL + "adminRole/queryDefaultRole",
		method: "post"
	})
}

// 部分角色列表
export function adminRoleGetRoleListAPI(data) {
	return request({
		url: BASE_URL + "adminRole/getRoleList",
		method: "post",
		data: data
	})
}

/**
 * 查询配置的角色范围
 * @param {*} data
 * @returns
 */
export function adminRoleQueryAuthRoleAPI(roleId) {
	return request({
		url: BASE_URL + `adminRole/queryAuthRole/${roleId}`,
		method: "post"
	})
}

/**
 * 更新配置的角色范围
 * @param {*} data
 * @returns
 */
export function adminRoleUpdateAuthRoleAPI(roleId, data) {
	return request({
		url: BASE_URL + `adminRole/updateAuthRole/${roleId}`,
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 批量修改密码接口
 * @param {*} data
 * password
 * id 用户数组
 */
export function adminUsersUpdatePwdAPI(data) {
	return request({
		url: BASE_URL + "adminUser/resetPassword",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 编辑登录名
 * @param {*} data
 * username
 * password
 * id
 */
export function adminUsersUsernameEditAPI(data) {
	return request({
		url: BASE_URL + "adminUser/usernameEdit",
		method: "post",
		data: data
	})
}

/**
 * 编辑登录名
 * @param {*} data
 * username
 * password
 * id
 * 可修改管理员
 */
export function adminUsersManagerUsernameEditAPI(data) {
	return request({
		url: BASE_URL + "adminUser/usernameEditByManager",
		method: "post",
		data: data
	})
}

/**
 * 用户状态修改
 * @param {*} data
 */
export function usersEditStatusAPI(data) {
	return request({
		url: BASE_URL + "adminUser/setUserStatus",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 用户导入模板
 * @param {*} data
 */
export const userImportTemplateURL =
	"https://www.72crm.com/npm/static/user_import.xlsx"
export function userImportTemplateAPI(data) {
	return request({
		url: BASE_URL + "adminUser/downloadExcel",
		method: "post",
		data: data,
		responseType: "blob"
	})
}

/**
 * 用户导入
 * @param {*} data
 */
export function userExcelImportAPI(data) {
	var param = new FormData()
	Object.keys(data).forEach(key => {
		param.append(key, data[key])
	})
	return request({
		url: BASE_URL + "adminUser/excelImport",
		method: "post",
		data: param,
		headers: {
			"Content-Type": "multipart/form-data"
		},
		timeout: 60000
	})
}

/**
 * 下载用户导入错误数据
 * @param {*} data
 *
 */
export function userErrorExcelDownAPI(data) {
	return request({
		url: BASE_URL + "adminUser/downExcel",
		method: "post",
		data: data,
		responseType: "blob"
	})
}

/**
 * 呼叫中心状态是否启用
 * @param {*} data
 */
export function crmCallAuthorizeAPI(data) {
	return request({
		url: BASE_URL + "crmCall/authorize",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 重置部门
 * @param {*} data
 */
export function adminUserSetUserDeptPI(data) {
	return request({
		url: BASE_URL + "adminUser/setUserDept",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 员工数量
 * @param {*} data
 */
export function adminUserCountNumOfUserAPI() {
	return request({
		url: BASE_URL + "adminUser/countNumOfUser",
		method: "post"
	})
}

/**
 * 员工批量导出
 * @param {*} data
 *
 */
export function adminUserAllExportExcelAPI(data) {
	return request({
		url: BASE_URL + "adminUser/allExportExcel",
		method: "post",
		responseType: "blob"
	})
}

/**
 * 选择员工导出
 * @param {*} data
 *
 */
export function adminUserBatchExportExcelAPI(data) {
	return request({
		url: BASE_URL + "adminUser/batchExportExcel",
		method: "post",
		data: data,
		responseType: "blob",
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

// 关联组织

/**
 * 企业关联审批
 * @param {*} data
 *
 */
export function adminCompanyCorrelationAuditExamineAPI(data) {
	return request({
		url: BASE_URL + "adminCompanyCorrelation/auditExamine",
		method: "post",
		data: data
	})
}

/**
 * 企业关联其它企业
 * @param {*} data
 *
 */
export function adminCompanyCorrelationAPI(data) {
	return request({
		url: BASE_URL + "adminCompanyCorrelation/companyCorrelation",
		method: "post",
		data: data
	})
}

/**
 * 分页查询信息
 * @param {*} data
 *
 */
export function adminCompanyCorrelationListAPI(data) {
	return request({
		url: BASE_URL + "adminCompanyCorrelation/queryPageList",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 企业关联其它企业
 * @param {*} data
 *
 */
export function adminCompanyCorrelationCompanyListAPI() {
	return request({
		url: BASE_URL + "adminCompanyCorrelation/queryUserCompanyList",
		method: "post"
	})
}

/**
 * 切换企业
 * @param {*} data
 *
 */
export function adminCompanyCorrelationSwitchAPI(data) {
	return request({
		url: BASE_URL + "adminCompanyCorrelation/switchCompany",
		method: "post",
		data: data
	})
}

/**
 * 取消关联
 * @param {*} data
 *
 */
export function adminCompanyCorrelationUnlinkAPI(data) {
	return request({
		url: BASE_URL + "adminCompanyCorrelation/unlink",
		method: "post",
		data: data
	})
}

/**
 * 获取企业分享链接token
 * @param {*} data
 *
 */
export function adminCompanyCorrelationGetTokenAPI(data) {
	return request({
		url: BASE_URL + "adminCompanyCorrelation/getToken",
		method: "post",
		data: data
	})
}

/**
 * 获取企业分享链接token详细信息
 * @param {*} data
 *
 */
export function adminCompanyCorrelationGetTokenInfoAPI(data) {
	return request({
		url: BASE_URL + "adminCompanyCorrelation/getTokenInfo",
		method: "post",
		data: data
	})
}

/**
 * 获取公司logo
 * @param {*} data
 *
 */
export function adminCompanyCorrelationGetLogoAPI(data) {
	return request({
		url: BASE_URL + "adminCompanyCorrelation/getCompanyLogo",
		method: "post",
		data: data,
		responseType: "blob"
	})
}

/**
 * 分页查询信息
 * @param {*} data
 *
 */
export function adminCompanyCorrelationUserListAPI(data) {
	return request({
		url: BASE_URL + `adminCompanyCorrelation/queryUserList/${data.key}`,
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}
/**
 * 设置部门排序
 * @param {*} data
 *
 */
export function adminDeptSetDeptSortAPI(data) {
	return request({
		url: BASE_URL + "adminDept/setDeptSort",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}
